package com.liantong.client.po;



public class Response {
	/**
	 * It is mapped to enum object StatusCode
	 */
	private int statusCode;

	/**
	 * Status description
	 */
	private String statusDesc;

	/**
	 * Any response value object can be set into it
	 */
	private Object body;

	private int count;

	private long timestamp;

	public Response() {}

	public Response(StatusCodeInterface statusCode) {
		this.statusCode = statusCode.getValue();
		this.statusDesc = statusCode.getDesc();
	}

	public Response(StatusCodeInterface statusCode, Object body) {
		this.statusCode = statusCode.getValue();
		this.statusDesc = statusCode.getDesc();
		this.body = body;
	}

	public Response(StatusCodeInterface statusCode, Object body, int count) {
		this.statusCode = statusCode.getValue();
		this.statusDesc = statusCode.getDesc();
		this.body = body;
		this.count = count;
	}

	public Response(StatusCodeInterface statusCode, Object body, int count, long timestamp) {
		this.statusCode = statusCode.getValue();
		this.statusDesc = statusCode.getDesc();
		this.body = body;
		this.count = count;
		this.timestamp = timestamp;
	}

	/**
	 * @return the statusCode
	 */
	public int getStatusCode() {
		return statusCode;
	}

	/**
	 * @param statusCode
	 *            the statusCode to set
	 */
	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	/**
	 * @return the statusDesc
	 */
	public String getStatusDesc() {
		return statusDesc;
	}

	/**
	 * @param statusDesc
	 *            the statusDesc to set
	 */
	public void setStatusDesc(String statusDesc) {
		this.statusDesc = statusDesc;
	}

	/**
	 * @return the body
	 */
	public Object getBody() {
		return body;
	}

	/**
	 * @param body
	 *            the body to set
	 */
	public void setBody(Object body) {
		this.body = body;
	}

	/**
	 * @return the count
	 */
	public int getCount() {
		return count;
	}

	/**
	 * @param count
	 *            the count to set
	 */
	public void setCount(int count) {
		this.count = count;
	}

	/**
	 * @return the timestamp
	 */
	public long getTimestamp() {
		return timestamp;
	}

	/**
	 * @param timestamp
	 *            the timestamp to set
	 */
	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((body == null) ? 0 : body.hashCode());
		result = prime * result + count;
		result = prime * result + statusCode;
		result = prime * result + ((statusDesc == null) ? 0 : statusDesc.hashCode());
		result = prime * result + (int) (timestamp ^ (timestamp >>> 32));
		return result;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Response other = (Response) obj;
		if (body == null) {
			if (other.body != null)
				return false;
		} else if (!body.equals(other.body))
			return false;
		if (count != other.count)
			return false;
		if (statusCode != other.statusCode)
			return false;
		if (statusDesc == null) {
			if (other.statusDesc != null)
				return false;
		} else if (!statusDesc.equals(other.statusDesc))
			return false;
		if (timestamp != other.timestamp)
			return false;
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Response [statusCode=" + statusCode + ", statusDesc=" + statusDesc + ", body=" + body + ", count=" + count + ", timestamp="
				+ timestamp + "]";
	}

}
